// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html



import Character from "../BASE/Character";
import Cspine from "../BASE/spineANDgif/Cspine";
import { gif } from "../BASE/spineANDgif/gif";
import GeZiManager from "../Manager/GeZiManager";
import { Message } from "../Message/Message";
import MessageCenter from "../Message/MessageCenter";
import JNUM from "../UIS/else/JNUmanager";
import weapon from "../equipment/weapon/weapon";
import state from "../game/time/state";
import turn from "../game/time/turn";

import SXX from "./SXX";


const {ccclass, property} = cc._decorator;

@ccclass
export default class S06 extends SXX {

    Snumber="S06"
    JX:boolean=false;
    cType: string ="human"
    MaxHP:number=6;
    JX1: string[]=["S迅猛","S敏捷","S强壮"];
JX2: string[]=["S左右勾拳","S升龙"];
xll:boolean=false
    start () {
     this.target=this.node.getComponent(Character)
     this.target.t1.push(this)
      // this.node.getChildByName("name").getComponent(cc.Label).string="拳击手"   
   
       // this.node.getComponent(Character).TNJJ[3]-=2;

      /*/
       this.node.getComponent(Character).changeE=function(pre:string) {

        this.node.getChildByName("shadow").getComponent(gif).moveToNextFrame(5,8,0)
  setTimeout(() => {
     this.node.getChildByName("shadow").getComponent(gif).changeF(5,1)
  }, 600);
  this.node.getChildByName("equ").getComponent(cc.Label).string=pre;

  switch (pre[0]) {
    
           case 'B': 
      
          if(this.body!=null){      this.body.remove();
           this.node.removeComponent(""+this.body.TheNumber)
        }
           this.node.addComponent(pre)
           this.body=this.node.getComponent(pre)
           this.node.getChildByName("B").getComponent(cc.Label).string=this.node.getComponent(pre).Cname
           break;
           case 'C': 
           this.shose.remove();
           this.node.removeComponent(""+this.shose.TheNumber)
           this.node.addComponent(pre);
           this.shose=this.node.getComponent(pre)

           this.node.getChildByName("C").getComponent(cc.Label).string=this.node.getComponent(pre).Cname
    //this.node.getComponent(Cspine).changE(pre,1);
           case 'D': 
           if(this.accessory!=null){ this.accessory.remove();  this.node.removeComponent(""+this.accessory.TheNumber)}
           this.node.addComponent(pre)
           this.accessory=this.node.getComponent(pre)
           this.node.getChildByName("D").getComponent(cc.Label).string=this.node.getComponent(pre).Cname
          
           break;
          
           break;

        default:
           break;
     }

  }*/
        }
  
     

xl(){
  MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],2,GeZiManager.PCP.Pturn,"Qi-")
  MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],3,GeZiManager.PCP.Pturn,"TN-")
  this.target.weapon.SH++;
 // this.xll=true
 // this.target.TNJJ[0]+=1
 // this.target.TNJJ[1]+=1
 this.node.parent.getComponent(JNUM).JNF("S升龙",this.target.ZB)  
}

T1(turn: number): void {
  
}



        skill2(): void {
          state.ST=9;
          GeZiManager.DLLM="S06"
        let a  = GeZiManager.PCP.ZB
        cc.find("Canvas/DituManager/New Node/AnimalManager/GUIManager").active=true;
        
        for(let c of GeZiManager.YuanGong){
        
        
        if(c.ZB==a){c.blue();  MessageCenter.MakeMessage("UIManager","change",2)}else c.null();
        
        }
        GeZiManager.GeZi=-2
        
        
        }






skill1(){
    GeZiManager.qing();
    MessageCenter.MakeMessage("UIManager", "change", -1);
   state.ST=9;
            GeZiManager.DLLM="S06"
    let AF = [1,3]
    let i = 0;
    switch (this.node.getComponent(Character).faceTo) {
      case 6: i = 1;
        break;
      case 8: i = 2;
        break;
      case 4: i = 3;
        break;
    }


    for (let n = 1; n <= i; n++) {
      this.node.getComponent(Character).turn6(AF);

    }
    let an: number[] = [];
    for (let mannger of AF) {



      an.push(this.node.getComponent(Character).findGe(mannger, 1));

    }

    GeZiManager.GeZis = [].concat(an);

    let c = new Message("", GeZiManager.GeZis, 1);
    for (let m of GeZiManager.YuanGong) {


      m.red();
if(GeZiManager.BanMove.includes(m.ZB)==false){
      m.ReceiveMessage(c);}

    }


  }

  remove(){ 
   
    }

QDS(n: number): void {
if (n==-2) {
  this.xl()
}else{
  let k=0
  if (this.BL[2]>0) {
  k=-1
  this.node.parent.getComponent(JNUM).JNF("S蝴蝶步",this.target.ZB)  
}
MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],3+k,GeZiManager.PCP.Pturn,"Qi-")
MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],4+2*k,GeZiManager.PCP.Pturn,"TN-")
  if(GeZiManager.PCP.walk2!=null){for(let w of GeZiManager.PCP.walk2){w.Walk2(GeZiManager.GeZi);}}  
  GeZiManager.PCP.To(n,0.6);MessageCenter.MakeMessage("UIManager","change",1);
  if(GeZiManager.PCP.walk3!=null){for(let w of GeZiManager.PCP.walk3){w.Walk3(GeZiManager.PCP.ZB);}}}
  this.node.parent.getComponent(JNUM).JNF("S蝴蝶步",this.target.ZB)  
}

choseS(n:string): void {
  switch (n) {
      case "S敏捷":GeZiManager.shanchu(this.JX1,"S敏捷");
          
          break;
         
          case "S强壮":GeZiManager.shanchu(this.JX1,"S强壮");    
          MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"MaxHP+")
          MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"HP+")
          
          break;    
          break;
          case "S迅猛":  GeZiManager.shanchu(this.JX1,"S迅猛");this.target.TNJJ[3]-=1
          
          break;
          case "S左右勾拳":if(this.target.weapon.TheNumber=="A506"){
      this.target.attack3.push(this.target.weapon)
      this.target.weapon.Attack3([]);
          }
           GeZiManager.shanchu(this.JX2,"S左右勾拳");
          break;
         
          case "S升龙":  GeZiManager.shanchu(this.JX2,"S升龙");this.target.TNJJ[3]-=1
          
          break;

        
  
      default:
          break;
  }
  console.log(n)
}








NWNA(e:string[],n:number){

  function A1(arr) {
   // return arr.filter(item =>(!item.startsWith('A')));
}


let j=A1(e)
  let c =this.getRAA(["FU0","FU1","FU2","FU3","TNS","TNS","TNS","HP","HP","qi","qi"],3)    
  let a

  return e
  
  
  
  }


  getTO (n: number):string[] {
    switch(n){

case 1:return ["S迅猛","S敏捷","S强壮"]

case 2:

return ["S左右勾拳","S升龙",this.JX1[0]]

case 3:
  let a=this.getRA(["FU0",'FU1','FU2','FU3'],1)
  return [this.JX1[0],this.JX2[0],a[0]]
default: 
let k="qi"
let k1=this.mArr1Arr2(this.JX1,this.JX2)
    if ( this.mArr1Arr2(this.JX1,this.JX2).length>0) {
        k= this.mArr1Arr2(this.JX1,this.JX2)[0] 
    }
    let o=this.getRA(["FU0",'FU1','FU2','FU3'],1)[0]
    if ( this.mArr1Arr2(this.JX1,this.JX2).length>1) {
       o= this.mArr1Arr2(this.JX1,this.JX2)[1] 
   }
    
   return[k,o,"TNS"]
}
}





getJNF(n: number[]): void {
  function sumArray(numbers: number[]): number {
    return numbers.reduce((sum, current) => sum + current, 0);
}
 
for (let index = 0; index < n[4]+n[5]; index++) {
  for( let a of n){if (index<4) {
     a++
  }}
}
 
 
 
 
if (n[0]>=1) {
   
  if (this.BL[0]==0) {
   this.target.TNJJ[3]-=1
   this.node.parent.getComponent(JNUM).JNF("S迅猛",this.target.ZB)  
  }
  this.BL[0]+=1 
}else{ 
  if (this.BL[0]>0) {
    this.target.TNJJ[3]+=1
        
  }
  
  
  this.BL[1]*=0

  
}//迅猛

 
 
  if (n[1]>=1) {
   
    if (this.BL[1]==0) {
      MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"MaxHP+")
          MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"HP+")

          this.node.parent.getComponent(JNUM).JNF("S强壮",this.target.ZB)  
    }
    this.BL[1]+=1 
  }else{ 
    if (this.BL[1]>0) {
      MessageCenter.MakeSHMessage('AM', [GeZiManager.PCP.ZB],1,GeZiManager.PCP.Pturn,"MaxHP-")
          
    }
    
    
    this.BL[1]*=0

    
  }//强壮
  




  if (n[3]>=1) {
    this.BL[2]+=1
    this.node.parent.getComponent(JNUM).JNF("S敏捷",this.target.ZB) 
  }else{  this.BL[2]*=0}//敏捷

  
  if (n[2]>=1) {
    this.BL[3]+=1
  }else{  this.BL[3]*=0}//升龙拳
 
  
  
  if (turn.round>=7){
    this.BL[4]+=1
  }else{  this.BL[4]*=0}//左右勾拳




}

}
   

